package com.example.bgmachine.bgmachine.handlouts;

import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

import com.example.bgmachine.bgmachine.R;
import com.example.bgmachine.bgmachine.goods.HomepageGridRightMenuAdapter;
import com.example.bgmachine.bgmachine.goods.HomepageGridRightMenuItemData;
import com.example.bgmachine.bgmachine.orders.OrderContentAdapter;
import com.example.bgmachine.bgmachine.orders.OrderContentData;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class HandloutFragment extends Fragment {
    private Context mContext = null;

    private GridView order_infor_item_gridvew = null;
    private ArrayList<HomepageGridRightMenuItemData> mHomepageGridRightMenuItemData = new ArrayList<HomepageGridRightMenuItemData>();
    private HomepageGridRightMenuAdapter mHomepageGridRightMenuAdapter = null;
    public HandlContentAdapter mHandlContentAdapter = null;
    public List<HandlContentData> mHandlContentData = null;
    public HandloutFragment() {

    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @NonNull Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.hanld_out_fragment_layout, container, false);
        mContext =view.getContext();
        order_infor_item_gridvew =  view.findViewById(R.id.order_infor_item_gridvew);
        mHandlContentData = new LinkedList<HandlContentData>();
        mHandlContentAdapter = new HandlContentAdapter(mContext,(LinkedList<HandlContentData>) mHandlContentData);
        if (order_infor_item_gridvew != null) {
            order_infor_item_gridvew.setAdapter(mHandlContentAdapter);
        }
        return view;
    }

    public void  addItem(HandlContentData orderContentData){
        if (mHandlContentAdapter != null) {
            mHandlContentAdapter.add(orderContentData);

            mHandlContentAdapter.notifyDataSetChanged();

        }
    }

}
